package com.tairanchina.joat.groovy

import com.tairanchina.joat.*
import com.tairanchina.joat.exception.JoatExecuteException
import com.tairanchina.joat.exception.JoatLifecycleException

/**
 * Created by 周靖捷 on 2016/10/17.
 */

@AnnotationPluginMeta(
        version = "1.0",
        installMode = PluginInstallMode.CONDITION_MODE,
        pluginId = "com.tairanchina.joat.groovy.DemoConditionGroovyPlugin"
)
class DemoConditionGroovyPlugin extends ConditionPlugin {
    @Override
    Object onCondition(PluginVariable variable, PluginEnvironment environment) throws JoatExecuteException {
        String code = variable.get("code");
        println(code);
        return code
    }

    @Override
    boolean isMatchedCondition(Object condition) {
        if (condition instanceof String) {
            String c = condition;
            return c.matches("qq");
        }
        return false
    }

    @Override
    void init() throws JoatLifecycleException {

    }

    @Override
    void load() throws JoatLifecycleException {

    }

    @Override
    void run() throws JoatLifecycleException {

    }

    @Override
    void disable() {

    }

    @Override
    void enable() {

    }

    @Override
    void stop() throws JoatLifecycleException {

    }

    @Override
    void destroy() throws JoatLifecycleException {

    }
}
